// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
// 引入fastclick-》解决300ms延迟的问题
import fastclick from 'fastclick'
// 官方推荐将fastclick绑定到body下，这样在body下的元素都不会有300ms的延迟
fastclick.attach(document.body)

// 引入addCart
import AddCart from '@/plugins/addCart/addCart'
Vue.use(AddCart)

//引入初始化css
import './common/style/index.less'
// rem初始化
import './common/reset.js'

//引入mint-ui
import {Lazyload, MessageBox} from 'mint-ui'
import 'mint-ui/lib/style.css'
//图片懒加载
Vue.use(Lazyload)
Vue.prototype.$msg = MessageBox


//监听全局路由变化
router.beforeEach((to, from, next) => {
  if (to.path === '/' || to.path === '/market' || to.path === '/cart' || to.path === '/mine') {
    store.state.tabBarShow = true
  } else {
    store.state.tabBarShow = false
  }
  //导航守卫实现地址转向
  /* if (to.path === '/cart') {
      if (!store.state.userInfo.id) {
        next('/login')
      }
  } */
  next()
})
import axios from 'axios'
//将axios添加到vue的原型中
Vue.prototype.$http = axios


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
